package com.luke.zk;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;

/**
 * @Descrtption CuratorConnection
 * @Author luke
 * @Date 2020/5/22
 **/
public class CuratorConnection {

    public static void main(String[] args) {

        RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000,3);

        CuratorFramework client = CuratorFrameworkFactory.builder()
                .connectString("192.168.0.17:2181")//地址端口
                .sessionTimeoutMs(5000)//会话超时
                .retryPolicy(retryPolicy)//重连机制
                .namespace("create")//命名空间
                .build();

        client.start();
        System.out.println(client.isStarted());
        client.close();

    }

}
